﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NJL.WebUsers.Handle
{
    /// <summary>
    /// HandlerEvaluation 的摘要说明
    /// </summary>
    public class HandlerEvaluation : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string strCompanyID = context.Request.QueryString["id"];
            string strPage = context.Request.QueryString["page"];

            NJL.BLL.NJL_COMPANY_EVALUATION bll = new BLL.NJL_COMPANY_EVALUATION();
            System.Data.DataSet ds = bll.GetList(100, "NJL_COMPANY_ID='"+strCompanyID+"'", " id ");

            string strResponseWriteString = "";

            if (ds != null && ds.Tables.Count>0 && ds.Tables[0].Rows.Count>0)
            {
                for (int i = 0; i<ds.Tables[0].Rows.Count; i++)
                {
                    Random r = new Random();
                    strResponseWriteString += "<div class=\"moveme\" id=\"vow_div_" + (i + 1).ToString() + "\" style=\"top:" + r.Next(150) + "px;left:" + r.Next(480) + "px;position:absolute\">";
                    strResponseWriteString += "     <div class=\"vow"+r.Next(1,8)+"\">";
                    strResponseWriteString += "         <div class=\"Caption\">";
                    strResponseWriteString += "             第[" + (i + 1).ToString() + "]条<div class=\"CloseButton\" onclick=\"vow_div_" + (i + 1).ToString() + ".style.display='none'\">";
                    strResponseWriteString += "                 ×";
                    strResponseWriteString += "             </div>";
                    strResponseWriteString += "         </div>";
                    strResponseWriteString += "         <div class=\"Body\">";
                    strResponseWriteString += "             " + ds.Tables[0].Rows[i]["COMPANY_EVALUATION"].ToString() + "</div>";
                    strResponseWriteString += "         <div class=\"Footer\">";
                    strResponseWriteString += "             <a target='_blank' href='/wanjia/" + ds.Tables[0].Rows[i]["CREATE_USER_ID"].ToString() + "-index.html'>" + (ds.Tables[0].Rows[i]["CREATE_USER_NAME"].ToString().Length > 8 ? ds.Tables[0].Rows[i]["CREATE_USER_NAME"].ToString().Substring(0, 8)+"..." : ds.Tables[0].Rows[i]["CREATE_USER_NAME"].ToString()) + "</a> at " + Convert.ToDateTime(ds.Tables[0].Rows[i]["CREATE_DATE_TIME"]).ToString("yyyy-MM-dd") + "</div>";
                    strResponseWriteString += "     </div>";
                    strResponseWriteString += " </div>";

                    System.Threading.Thread.Sleep(1);
                }
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(strResponseWriteString);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}